package com.example.programming.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.programming.sys.entity.EduCourse;
import com.example.programming.sys.entity.StuCourse;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口 chrimer
 * </p>
 *
 * @author chrimer
 * @since 2020-09-08
 */
public interface StuCourseMapper extends BaseMapper<StuCourse> {

    @Select("SELECT couseid FROM stu_course where stuid = #{id}")
    public List<StuCourse> getId(String id);
    @Select("SELECT id,title,lesson_num,cover FROM edu_course WHERE id = #{id}")
    public List<EduCourse> message(String id);
    @Select("SELECT couseid FROM stu_course where couseid = #{courseid} and stuid=#{id}")
    String course(String courseid,String id);
    @Select("SELECT subject_parent_id FROM edu_course where id = #{courseid}")
    String rCourse(String courseid);

    //取出该类型课程中销量最好的4个课程
    @Select("SELECT * FROM edu_course WHERE subject_parent_id = #{id} ORDER BY buy_count desc LIMIT 4")
    public List<EduCourse> courseMessage(String id);

    //取出销量最好的4个课程
    @Select("SELECT * FROM edu_course ORDER BY buy_count desc LIMIT 4")
    public List<EduCourse> bCourseMessage();

}
